home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Mac / Demo / scripting / Standard_Suite.py < prev    next >
Encoding:
Python Source  |  2000-06-23  |  8.1 KB  |  273 lines

  1. """Suite Standard Suite: Common terms for most applications
  2. Level 1, version 1
  3.  
  4. Generated from flap:Programma's:Eudora Light
  5. AETE/AEUT resource version 2/16, language 0, script 0
  6. """
  7.  
  8. import aetools
  9. import MacOS
  10.  
  11. _code = 'CoRe'
  12.  
  13. class Standard_Suite:
  14.  
  15.     def close(self, _object, _attributes={}, **_arguments):
  16.         """close: Close an object
  17.         Required argument: the object to close
  18.         Keyword argument _attributes: AppleEvent attribute dictionary
  19.         """
  20.         _code = 'core'
  21.         _subcode = 'clos'
  22.  
  23.         if _arguments: raise TypeError, 'No optional args expected'
  24.         _arguments['----'] = _object
  25.  
  26.  
  27.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  28.                 _arguments, _attributes)
  29.         if _arguments.has_key('errn'):
  30.             raise aetools.Error, aetools.decodeerror(_arguments)
  31.         # XXXX Optionally decode result
  32.         if _arguments.has_key('----'):
  33.             return _arguments['----']
  34.  
  35.     _argmap_count = {
  36.         'each' : 'kocl',
  37.     }
  38.  
  39.     def count(self, _object, _attributes={}, **_arguments):
  40.         """count: Return the number of elements of a particular class within an object
  41.         Required argument: the object whose elements are to be counted
  42.         Keyword argument each: the class of the elements to be counted. Keyword 'each' is optional in AppleScript
  43.         Keyword argument _attributes: AppleEvent attribute dictionary
  44.         Returns: the number of elements
  45.         """
  46.         _code = 'core'
  47.         _subcode = 'cnte'
  48.  
  49.         aetools.keysubst(_arguments, self._argmap_count)
  50.         _arguments['----'] = _object
  51.  
  52.  
  53.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  54.                 _arguments, _attributes)
  55.         if _arguments.has_key('errn'):
  56.             raise aetools.Error, aetools.decodeerror(_arguments)
  57.         # XXXX Optionally decode result
  58.         if _arguments.has_key('----'):
  59.             return _arguments['----']
  60.  
  61.     def exists(self, _object, _attributes={}, **_arguments):
  62.         """exists: Verify if an object exists
  63.         Required argument: the object in question
  64.         Keyword argument _attributes: AppleEvent attribute dictionary
  65.         Returns: true if it exists, false if not
  66.         """
  67.         _code = 'core'
  68.         _subcode = 'doex'
  69.  
  70.         if _arguments: raise TypeError, 'No optional args expected'
  71.         _arguments['----'] = _object
  72.  
  73.  
  74.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  75.                 _arguments, _attributes)
  76.         if _arguments.has_key('errn'):
  77.             raise aetools.Error, aetools.decodeerror(_arguments)
  78.         # XXXX Optionally decode result
  79.         if _arguments.has_key('----'):
  80.             return _arguments['----']
  81.  
  82.     def get(self, _object, _attributes={}, **_arguments):
  83.         """get: Get the data for an object
  84.         Required argument: the object whose data is to be returned
  85.         Keyword argument _attributes: AppleEvent attribute dictionary
  86.         Returns: the data from the object
  87.         """
  88.         _code = 'core'
  89.         _subcode = 'getd'
  90.  
  91.         if _arguments: raise TypeError, 'No optional args expected'
  92.         _arguments['----'] = _object
  93.  
  94.  
  95.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  96.                 _arguments, _attributes)
  97.         if _arguments.has_key('errn'):
  98.             raise aetools.Error, aetools.decodeerror(_arguments)
  99.         # XXXX Optionally decode result
  100.         if _arguments.has_key('----'):
  101.             return _arguments['----']
  102.  
  103.     _argmap_make = {
  104.         'new' : 'kocl',
  105.         'at' : 'insh',
  106.     }
  107.  
  108.     def make(self, _no_object=None, _attributes={}, **_arguments):
  109.         """make: Make a new element
  110.         Keyword argument new: the class of the new element. Keyword 'new' is optional in AppleScript
  111.         Keyword argument at: the location at which to insert the element
  112.         Keyword argument _attributes: AppleEvent attribute dictionary
  113.         Returns: to the new object
  114.         """
  115.         _code = 'core'
  116.         _subcode = 'crel'
  117.  
  118.         aetools.keysubst(_arguments, self._argmap_make)
  119.         if _no_object != None: raise TypeError, 'No direct arg expected'
  120.  
  121.  
  122.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  123.                 _arguments, _attributes)
  124.         if _arguments.has_key('errn'):
  125.             raise aetools.Error, aetools.decodeerror(_arguments)
  126.         # XXXX Optionally decode result
  127.         if _arguments.has_key('----'):
  128.             return _arguments['----']
  129.  
  130.     _argmap_move = {
  131.         'to' : 'insh',
  132.     }
  133.  
  134.     def move(self, _object, _attributes={}, **_arguments):
  135.         """move: Move object to a new location
  136.         Required argument: the object to move
  137.         Keyword argument to: the new location for the object
  138.         Keyword argument _attributes: AppleEvent attribute dictionary
  139.         Returns: to the object after they have been moved
  140.         """
  141.         _code = 'core'
  142.         _subcode = 'move'
  143.  
  144.         aetools.keysubst(_arguments, self._argmap_move)
  145.         _arguments['----'] = _object
  146.  
  147.  
  148.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  149.                 _arguments, _attributes)
  150.         if _arguments.has_key('errn'):
  151.             raise aetools.Error, aetools.decodeerror(_arguments)
  152.         # XXXX Optionally decode result
  153.         if _arguments.has_key('----'):
  154.             return _arguments['----']
  155.  
  156.     _argmap_duplicate = {
  157.         'to' : 'insh',
  158.     }
  159.  
  160.     def duplicate(self, _object, _attributes={}, **_arguments):
  161.         """duplicate: Make a duplicate object
  162.         Required argument: the object to move
  163.         Keyword argument to: the new location for the object
  164.         Keyword argument _attributes: AppleEvent attribute dictionary
  165.         Returns: to the object after they have been moved
  166.         """
  167.         _code = 'core'
  168.         _subcode = 'clon'
  169.  
  170.         aetools.keysubst(_arguments, self._argmap_duplicate)
  171.         _arguments['----'] = _object
  172.  
  173.  
  174.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  175.                 _arguments, _attributes)
  176.         if _arguments.has_key('errn'):
  177.             raise aetools.Error, aetools.decodeerror(_arguments)
  178.         # XXXX Optionally decode result
  179.         if _arguments.has_key('----'):
  180.             return _arguments['----']
  181.  
  182.     def open(self, _object, _attributes={}, **_arguments):
  183.         """open: Open the specified object
  184.         Required argument: list of objects to open
  185.         Keyword argument _attributes: AppleEvent attribute dictionary
  186.         """
  187.         _code = 'aevt'
  188.         _subcode = 'odoc'
  189.  
  190.         if _arguments: raise TypeError, 'No optional args expected'
  191.         _arguments['----'] = _object
  192.  
  193.  
  194.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  195.                 _arguments, _attributes)
  196.         if _arguments.has_key('errn'):
  197.             raise aetools.Error, aetools.decodeerror(_arguments)
  198.         # XXXX Optionally decode result
  199.         if _arguments.has_key('----'):
  200.             return _arguments['----']
  201.  
  202.     def _print(self, _object, _attributes={}, **_arguments):
  203.         """print: Print the specified message
  204.         Required argument: the message to print
  205.         Keyword argument _attributes: AppleEvent attribute dictionary
  206.         """
  207.         _code = 'aevt'
  208.         _subcode = 'pdoc'
  209.  
  210.         if _arguments: raise TypeError, 'No optional args expected'
  211.         _arguments['----'] = _object
  212.  
  213.  
  214.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  215.                 _arguments, _attributes)
  216.         if _arguments.has_key('errn'):
  217.             raise aetools.Error, aetools.decodeerror(_arguments)
  218.         # XXXX Optionally decode result
  219.         if _arguments.has_key('----'):
  220.             return _arguments['----']
  221.  
  222.     def save(self, _object, _attributes={}, **_arguments):
  223.         """save: Save an object
  224.         Required argument: the composition message to save
  225.         Keyword argument _attributes: AppleEvent attribute dictionary
  226.         """
  227.         _code = 'core'
  228.         _subcode = 'save'
  229.  
  230.         if _arguments: raise TypeError, 'No optional args expected'
  231.         _arguments['----'] = _object
  232.  
  233.  
  234.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  235.                 _arguments, _attributes)
  236.         if _arguments.has_key('errn'):
  237.             raise aetools.Error, aetools.decodeerror(_arguments)
  238.         # XXXX Optionally decode result
  239.         if _arguments.has_key('----'):
  240.             return _arguments['----']
  241.  
  242.     _argmap_set = {
  243.         'to' : 'data',
  244.     }
  245.  
  246.     def set(self, _object, _attributes={}, **_arguments):
  247.         """set: Set an object's data
  248.         Required argument: the object to change
  249.         Keyword argument to: the new value
  250.         Keyword argument _attributes: AppleEvent attribute dictionary
  251.         """
  252.         _code = 'core'
  253.         _subcode = 'setd'
  254.  
  255.         aetools.keysubst(_arguments, self._argmap_set)
  256.         _arguments['----'] = _object
  257.  
  258.  
  259.         _reply, _arguments, _attributes = self.send(_code, _subcode,
  260.                 _arguments, _attributes)
  261.         if _arguments.has_key('errn'):
  262.             raise aetools.Error, aetools.decodeerror(_arguments)
  263.         # XXXX Optionally decode result
  264.         if _arguments.has_key('----'):
  265.             return _arguments['----']
  266.  
  267.  
  268. #    Class 'application' ('capp') -- 'An application program'
  269. #        property 'version' ('vers') 'itxt' -- 'the version number' []
  270. #        property 'selected text' ('eStx') 'TEXT' -- 'the text of the user\325s current selection' []
  271. #        element 'euMF' as ['indx', 'name']
  272. #        element 'ePrf' as ['indx']
  273.